package com.intramirror.product.mapper;

import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;

/**
 * Created on 2018/1/4.
 * @author 123
 */
public interface PromotionRuleMapper {
    List<Map<String, Object>> listExcludeRulePromotion(Long promotionId);

    List<Map<String, Object>> listIncludeRulePromotion(Long promotionId);

    void removeSnapshotProduct(Long promotionId);

    void generateRuleToSnapshotProduct(@Param("promotionId") Long promotionId, @Param("promotionRuleId") Long promotionRuleId, @Param("vendorId") Long vendorId,
            @Param("seasonCode") String seasonCode, @Param("brandId") Long brandId, @Param("category") List<Long> category);

    void removeExcludeSnapshotProduct(@Param("promotionId") Long promotionId, @Param("vendorId") Long vendorId, @Param("seasonCode") String seasonCode,
            @Param("brandId") Long brandId, @Param("category") List<Long> category);

    List<Map<String, Object>> addProductForIncludeRule(@Param("promotionId") Long promotionId, @Param("promotionRuleId") Long promotionRuleId,
            @Param("productId") Long productId);

    List<Map<String, Object>> addProductsForIncludeRule(@Param("promotionId") Long promotionId, @Param("promotionRuleId") Long promotionRuleId,
            @Param("vendorId") Long vendorId, @Param("seasonCode") String seasonCode, @Param("brandId") Long brandId, @Param("category") List<Long> category,
            @Param("productIds") List<Long> productIds);

    void removeExcludeProductFromSnapshotProduct(Long promotionId);

    void removeExcludeProductGroupFromSnapshot(Long promotionId);

    List<Map<String, Object>> selectProductFromExcludeProductRule(@Param("promotionId") Long promotionId, @Param("productId") Long productId);

    List<Map<String, Object>> selectProductFromExcludeGroupRule(@Param("promotionId") Long promotionId, @Param("productId") Long productId);

    List<Map<String, Object>> getPromotionBoutiqueHasRuleList(Long promotionId);

    List<Map<String, Object>> getPromotionBoutiqueSeason(Map<String, Object> params);
    List<Map<String, Object>> getPromotionBoutiqueProductCountBySeason(Map<String, Object> params);

    Integer getPromotionBoutiqueExcludeProductCount(Long promotionId);

    Map<String, Object> getPromotionById(@Param("promotionId") Long promotionId);

    int removeIncludeRule(@Param("tableName") String tableName, @Param("seasonCode") String seasonCode, @Param("vendor") Long vendor,
            @Param("promotionId") Long promotionId);

    int removePromotionRuleByVendor(@Param("seasonCode") String seasonCode, @Param("vendor") Long vendor, @Param("promotionId") Long promotionId);

    List<Map<String, Object>> getUnRefreshCampaignRule();

    /**
     * 更新t_promotion表中refresh_at为当前时间
     * @param promotionId
     * @return
     */
    int updatePromotionRefreshAt(@Param("promotionId") Long promotionId);

    List<Map<String, Object>> getTags(@Param("vendorId") Long vendorId, @Param("orderBy") String orderBy);

    int addExcludeProductGroup(@Param("promotionId") Long promotionId, @Param("tagId") Long tagId);

    List<Map<String, Object>> getVendorInfoByTag();

    int deleteExcludeProductGroup(@Param("ids") List<Long> ids);

    List<Map<String, Object>> getExcludeProductGroupByPromotionId(@Param("promotionId") Long promotionId);

    int updatePromotionSaveTime(@Param("promotionId") Long promotionId);

    int updatePromotionSaveTimes(@Param("promotionIds") List<Long> promotionIds);

    Long findPromotionExcludeGroupByTagId(@Param("tagId") Long tagId, @Param("promotionId") Long promotionId);

    int updatePromotionSaveTimeByExcludeProductGroupIds(@Param("ids") List<Long> ids);
}

